<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>安全访问认证</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .login-container {
            width: 100%;
            max-width: 420px;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            padding: 40px;
            text-align: center;
            animation: fadeIn 0.5s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .logo {
            width: 80px;
            height: 80px;
            margin: 0 auto 20px;
            background: linear-gradient(45deg, #6a11cb, #2575fc);
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 32px;
            font-weight: bold;
        }

        h2 {
            color: #333;
            margin-bottom: 10px;
            font-size: 28px;
            font-weight: 600;
        }

        .subtitle {
            color: #666;
            margin-bottom: 30px;
            font-size: 16px;
        }

        .form-group {
            margin-bottom: 20px;
            text-align: left;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #444;
            font-size: 14px;
        }

        .input-field {
            position: relative;
        }

        input[type="password"] {
            width: 100%;
            padding: 14px 20px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s;
            background: #f9f9f9;
        }

        input[type="password"]:focus {
            border-color: #2575fc;
            box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.2);
            outline: none;
            background: #fff;
        }

        .password-toggle {
            position: absolute;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            background: none;
            border: none;
            color: #777;
            cursor: pointer;
        }

        .password-hint {
            font-size: 13px;
            color: #777;
            margin-top: 8px;
        }

        .btn-login {
            width: 100%;
            padding: 16px;
            background: linear-gradient(45deg, #6a11cb, #2575fc);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            transition: all 0.3s;
            margin-top: 10px;
        }

        .btn-login:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(37, 117, 252, 0.4);
        }

        .error {
            color: #ff4757;
            text-align: center;
            margin: 20px 0;
            padding: 12px;
            background: #ffecee;
            border-radius: 8px;
            font-size: 14px;
            animation: shake 0.5s;
        }

        .message {
            color: #2ed573;
            text-align: center;
            margin: 20px 0;
            padding: 12px;
            background: #e9f9ef;
            border-radius: 8px;
            font-size: 14px;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-5px); }
            75% { transform: translateX(5px); }
        }

        .footer {
            margin-top: 30px;
            color: #777;
            font-size: 13px;
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="logo">GT</div>
    <h2>安全访问认证</h2>
    <p class="subtitle">请输入访问密码进入系统</p>

    <!-- 成功消息 -->
    <div th:if="${message}" class="message" th:text="${message}"></div>

    <form th:action="@{/login}" method="post">
        <!-- 隐藏的用户名字段 -->
        <input type="hidden" name="username" value="user" />

        <div class="form-group">
            <label for="password">访问密码</label>
            <div class="input-field">
                <input type="password"
                       id="password"
                       name="password"
                       placeholder="请输入访问密码"
                       required
                       autofocus />
                <button type="button" class="password-toggle" onclick="togglePassword()">
                    👁️
                </button>
            </div>
<!--            <div class="password-hint">默认密码: 123456</div>-->
        </div>

        <button type="submit" class="btn-login">进入系统</button>

        <!-- 错误消息 -->
        <div th:if="${error}" class="error" th:text="${error}"></div>
    </form>

    <div class="footer">
        <p>© 2025 安全访问系统</p>
    </div>
</div>

<script>
    function togglePassword() {
        const passwordInput = document.getElementById('password');
        const toggleButton = document.querySelector('.password-toggle');

        if (passwordInput.type === 'password') {
            passwordInput.type = 'text';
            toggleButton.textContent = '🔒';
        } else {
            passwordInput.type = 'password';
            toggleButton.textContent = '👁️';
        }
    }
</script>
</body>
</html>